﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Persistence.Migrations
{
    public partial class All : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AdditionalServices",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
                        DailyPrice = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AdditionalServices", x => x.Id);
                }
            );

            migrationBuilder.CreateTable(
                name: "Brands",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Brands", x => x.Id);
                }
            );

            migrationBuilder.CreateTable(
                name: "Colors",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Colors", x => x.Id);
                }
            );

            migrationBuilder.CreateTable(
                name: "Fuels",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Fuels", x => x.Id);
                }
            );

            migrationBuilder.CreateTable(
                name: "OperationClaims",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OperationClaims", x => x.Id);
                }
            );

            migrationBuilder.CreateTable(
                name: "RentalBranches",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        City = table.Column<int>(type: "int", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RentalBranches", x => x.Id);
                }
            );

            migrationBuilder.CreateTable(
                name: "Transmissions",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Transmissions", x => x.Id);
                }
            );

            migrationBuilder.CreateTable(
                name: "Users",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                        LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                        Email = table.Column<string>(type: "nvarchar(450)", nullable: false),
                        PasswordSalt = table.Column<byte[]>(type: "varbinary(max)", nullable: false),
                        PasswordHash = table.Column<byte[]>(type: "varbinary(max)", nullable: false),
                        Status = table.Column<bool>(type: "bit", nullable: false, defaultValue: true),
                        AuthenticatorType = table.Column<int>(type: "int", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Users", x => x.Id);
                }
            );

            migrationBuilder.CreateTable(
                name: "Models",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        BrandId = table.Column<int>(type: "int", nullable: false),
                        FuelId = table.Column<int>(type: "int", nullable: false),
                        TransmissionId = table.Column<int>(type: "int", nullable: false),
                        Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
                        DailyPrice = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
                        ImageUrl = table.Column<string>(type: "nvarchar(max)", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Models", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Models_Brands_BrandId",
                        column: x => x.BrandId,
                        principalTable: "Brands",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                    table.ForeignKey(
                        name: "FK_Models_Fuels_FuelId",
                        column: x => x.FuelId,
                        principalTable: "Fuels",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                    table.ForeignKey(
                        name: "FK_Models_Transmissions_TransmissionId",
                        column: x => x.TransmissionId,
                        principalTable: "Transmissions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateTable(
                name: "Customers",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        UserId = table.Column<int>(type: "int", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Customers", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Customers_Users_UserId",
                        column: x => x.UserId,
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateTable(
                name: "EmailAuthenticators",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        UserId = table.Column<int>(type: "int", nullable: false),
                        ActivationKey = table.Column<string>(type: "nvarchar(max)", nullable: true),
                        IsVerified = table.Column<bool>(type: "bit", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_EmailAuthenticators", x => x.Id);
                    table.ForeignKey(
                        name: "FK_EmailAuthenticators_Users_UserId",
                        column: x => x.UserId,
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateTable(
                name: "OtpAuthenticators",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        UserId = table.Column<int>(type: "int", nullable: false),
                        SecretKey = table.Column<byte[]>(type: "varbinary(max)", nullable: false),
                        IsVerified = table.Column<bool>(type: "bit", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OtpAuthenticators", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OtpAuthenticators_Users_UserId",
                        column: x => x.UserId,
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateTable(
                name: "RefreshTokens",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        UserId = table.Column<int>(type: "int", nullable: false),
                        Token = table.Column<string>(type: "nvarchar(max)", nullable: false),
                        Expires = table.Column<DateTime>(type: "datetime2", nullable: false),
                        Created = table.Column<DateTime>(type: "datetime2", nullable: false),
                        CreatedByIp = table.Column<string>(type: "nvarchar(max)", nullable: false),
                        Revoked = table.Column<DateTime>(type: "datetime2", nullable: true),
                        RevokedByIp = table.Column<string>(type: "nvarchar(max)", nullable: true),
                        ReplacedByToken = table.Column<string>(type: "nvarchar(max)", nullable: true),
                        ReasonRevoked = table.Column<string>(type: "nvarchar(max)", nullable: true),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RefreshTokens", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RefreshTokens_Users_UserId",
                        column: x => x.UserId,
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateTable(
                name: "UserOperationClaims",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        UserId = table.Column<int>(type: "int", nullable: false),
                        OperationClaimId = table.Column<int>(type: "int", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserOperationClaims", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserOperationClaims_OperationClaims_OperationClaimId",
                        column: x => x.OperationClaimId,
                        principalTable: "OperationClaims",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                    table.ForeignKey(
                        name: "FK_UserOperationClaims_Users_UserId",
                        column: x => x.UserId,
                        principalTable: "Users",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateTable(
                name: "Cars",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        ColorId = table.Column<int>(type: "int", nullable: false),
                        ModelId = table.Column<int>(type: "int", nullable: false),
                        RentalBranchId = table.Column<int>(type: "int", nullable: false),
                        State = table.Column<int>(type: "int", nullable: false),
                        Kilometer = table.Column<int>(type: "int", nullable: false),
                        ModelYear = table.Column<short>(type: "smallint", nullable: false),
                        Plate = table.Column<string>(type: "nvarchar(max)", nullable: false),
                        MinFindeksCreditRate = table.Column<short>(type: "smallint", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Cars", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Cars_Colors_ColorId",
                        column: x => x.ColorId,
                        principalTable: "Colors",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                    table.ForeignKey(
                        name: "FK_Cars_Models_ModelId",
                        column: x => x.ModelId,
                        principalTable: "Models",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                    table.ForeignKey(
                        name: "FK_Cars_RentalBranches_RentalBranchId",
                        column: x => x.RentalBranchId,
                        principalTable: "RentalBranches",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateTable(
                name: "CorporateCustomers",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        CustomerId = table.Column<int>(type: "int", nullable: false),
                        CompanyName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                        TaxNo = table.Column<string>(type: "nvarchar(450)", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CorporateCustomers", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CorporateCustomers_Customers_CustomerId",
                        column: x => x.CustomerId,
                        principalTable: "Customers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateTable(
                name: "FindeksCreditRates",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        CustomerId = table.Column<int>(type: "int", nullable: false),
                        Score = table.Column<short>(type: "smallint", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_FindeksCreditRates", x => x.Id);
                    table.ForeignKey(
                        name: "FK_FindeksCreditRates_Customers_CustomerId",
                        column: x => x.CustomerId,
                        principalTable: "Customers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateTable(
                name: "IndividualCustomers",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        CustomerId = table.Column<int>(type: "int", nullable: false),
                        FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                        LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                        NationalIdentity = table.Column<string>(type: "nvarchar(450)", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IndividualCustomers", x => x.Id);
                    table.ForeignKey(
                        name: "FK_IndividualCustomers_Customers_CustomerId",
                        column: x => x.CustomerId,
                        principalTable: "Customers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateTable(
                name: "Invoices",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        CustomerId = table.Column<int>(type: "int", nullable: false),
                        No = table.Column<string>(type: "nvarchar(max)", nullable: false),
                        CreatedDate = table.Column<DateTime>(
                            type: "datetime2",
                            nullable: false,
                            defaultValue: new DateTime(2022, 10, 17, 19, 7, 25, 692, DateTimeKind.Local).AddTicks(9094)
                        ),
                        RentalStartDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        RentalEndDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        TotalRentalDate = table.Column<short>(type: "smallint", nullable: false),
                        RentalPrice = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Invoices", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Invoices_Customers_CustomerId",
                        column: x => x.CustomerId,
                        principalTable: "Customers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateTable(
                name: "CarDamages",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        CarId = table.Column<int>(type: "int", nullable: false),
                        DamageDescription = table.Column<string>(type: "nvarchar(max)", nullable: false),
                        IsFixed = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CarDamages", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CarDamages_Cars_CarId",
                        column: x => x.CarId,
                        principalTable: "Cars",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.CreateTable(
                name: "Rentals",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        CarId = table.Column<int>(type: "int", nullable: false),
                        CustomerId = table.Column<int>(type: "int", nullable: false),
                        RentStartRentalBranchId = table.Column<int>(type: "int", nullable: false),
                        RentEndRentalBranchId = table.Column<int>(type: "int", nullable: true),
                        RentStartDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        RentEndDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        ReturnDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                        RentStartKilometer = table.Column<int>(type: "int", nullable: false),
                        RentEndKilometer = table.Column<int>(type: "int", nullable: true),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Rentals", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Rentals_Cars_CarId",
                        column: x => x.CarId,
                        principalTable: "Cars",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                    table.ForeignKey(
                        name: "FK_Rentals_Customers_CustomerId",
                        column: x => x.CustomerId,
                        principalTable: "Customers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                    table.ForeignKey(
                        name: "FK_Rentals_RentalBranches_RentEndRentalBranchId",
                        column: x => x.RentEndRentalBranchId,
                        principalTable: "RentalBranches",
                        principalColumn: "Id"
                    );
                    table.ForeignKey(
                        name: "FK_Rentals_RentalBranches_RentStartRentalBranchId",
                        column: x => x.RentStartRentalBranchId,
                        principalTable: "RentalBranches",
                        principalColumn: "Id"
                    );
                }
            );

            migrationBuilder.CreateTable(
                name: "RentalsAdditionalServices",
                columns: table =>
                    new
                    {
                        Id = table.Column<int>(type: "int", nullable: false).Annotation("SqlServer:Identity", "1, 1"),
                        RentalId = table.Column<int>(type: "int", nullable: false),
                        AdditionalServiceId = table.Column<int>(type: "int", nullable: false),
                        CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                        UpdatedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                    },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RentalsAdditionalServices", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RentalsAdditionalServices_AdditionalServices_AdditionalServiceId",
                        column: x => x.AdditionalServiceId,
                        principalTable: "AdditionalServices",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                    table.ForeignKey(
                        name: "FK_RentalsAdditionalServices_Rentals_RentalId",
                        column: x => x.RentalId,
                        principalTable: "Rentals",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade
                    );
                }
            );

            migrationBuilder.InsertData(
                table: "AdditionalServices",
                columns: new[] { "Id", "CreatedDate", "DailyPrice", "Name", "UpdatedDate" },
                values: new object[,]
                {
                    {
                        1,
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                        200m,
                        "Baby Seat",
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                    },
                    {
                        2,
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                        300m,
                        "Scooter",
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                    }
                }
            );

            migrationBuilder.InsertData(
                table: "Brands",
                columns: new[] { "Id", "CreatedDate", "Name", "UpdatedDate" },
                values: new object[,]
                {
                    {
                        1,
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                        "BMW",
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                    },
                    {
                        2,
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                        "Mercedes",
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                    }
                }
            );

            migrationBuilder.InsertData(
                table: "Colors",
                columns: new[] { "Id", "CreatedDate", "Name", "UpdatedDate" },
                values: new object[,]
                {
                    {
                        1,
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                        "Red",
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                    },
                    {
                        2,
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                        "Blue",
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                    }
                }
            );

            migrationBuilder.InsertData(
                table: "Fuels",
                columns: new[] { "Id", "CreatedDate", "Name", "UpdatedDate" },
                values: new object[,]
                {
                    {
                        1,
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                        "Diesel",
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                    },
                    {
                        2,
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                        "Electric",
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                    }
                }
            );

            migrationBuilder.InsertData(
                table: "OperationClaims",
                columns: new[] { "Id", "CreatedDate", "Name", "UpdatedDate" },
                values: new object[]
                {
                    1,
                    new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                    "admin",
                    new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                }
            );

            migrationBuilder.InsertData(
                table: "RentalBranches",
                columns: new[] { "Id", "City", "CreatedDate", "UpdatedDate" },
                values: new object[,]
                {
                    {
                        1,
                        6,
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                    },
                    {
                        2,
                        7,
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                    }
                }
            );

            migrationBuilder.InsertData(
                table: "Transmissions",
                columns: new[] { "Id", "CreatedDate", "Name", "UpdatedDate" },
                values: new object[,]
                {
                    {
                        1,
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                        "Manuel",
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                    },
                    {
                        2,
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                        "Automatic",
                        new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                    }
                }
            );

            migrationBuilder.InsertData(
                table: "Models",
                columns: new[]
                {
                    "Id",
                    "BrandId",
                    "CreatedDate",
                    "DailyPrice",
                    "FuelId",
                    "ImageUrl",
                    "Name",
                    "TransmissionId",
                    "UpdatedDate"
                },
                values: new object[]
                {
                    1,
                    1,
                    new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                    1000m,
                    1,
                    "",
                    "418i",
                    2,
                    new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                }
            );

            migrationBuilder.InsertData(
                table: "Models",
                columns: new[]
                {
                    "Id",
                    "BrandId",
                    "CreatedDate",
                    "DailyPrice",
                    "FuelId",
                    "ImageUrl",
                    "Name",
                    "TransmissionId",
                    "UpdatedDate"
                },
                values: new object[]
                {
                    2,
                    2,
                    new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                    600m,
                    2,
                    "",
                    "CLA 180D",
                    1,
                    new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                }
            );

            migrationBuilder.InsertData(
                table: "Cars",
                columns: new[]
                {
                    "Id",
                    "State",
                    "ColorId",
                    "CreatedDate",
                    "Kilometer",
                    "MinFindeksCreditRate",
                    "ModelId",
                    "ModelYear",
                    "Plate",
                    "RentalBranchId",
                    "UpdatedDate"
                },
                values: new object[]
                {
                    1,
                    1,
                    1,
                    new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                    1000,
                    (short)500,
                    1,
                    (short)2018,
                    "07ABC07",
                    1,
                    new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                }
            );

            migrationBuilder.InsertData(
                table: "Cars",
                columns: new[]
                {
                    "Id",
                    "State",
                    "ColorId",
                    "CreatedDate",
                    "Kilometer",
                    "MinFindeksCreditRate",
                    "ModelId",
                    "ModelYear",
                    "Plate",
                    "RentalBranchId",
                    "UpdatedDate"
                },
                values: new object[]
                {
                    2,
                    2,
                    2,
                    new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                    1000,
                    (short)1100,
                    2,
                    (short)2018,
                    "15ABC15",
                    2,
                    new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
                }
            );

            migrationBuilder.CreateIndex(name: "UK_AdditionalServices_Name", table: "AdditionalServices", column: "Name", unique: true);

            migrationBuilder.CreateIndex(name: "UK_Brands_Name", table: "Brands", column: "Name", unique: true);

            migrationBuilder.CreateIndex(name: "IX_CarDamages_CarId", table: "CarDamages", column: "CarId");

            migrationBuilder.CreateIndex(name: "IX_Cars_ColorId", table: "Cars", column: "ColorId");

            migrationBuilder.CreateIndex(name: "IX_Cars_ModelId", table: "Cars", column: "ModelId");

            migrationBuilder.CreateIndex(name: "IX_Cars_RentalBranchId", table: "Cars", column: "RentalBranchId");

            migrationBuilder.CreateIndex(name: "UK_Colors_Name", table: "Colors", column: "Name", unique: true);

            migrationBuilder.CreateIndex(
                name: "UK_CorporateCustomers_CustomerId",
                table: "CorporateCustomers",
                column: "CustomerId",
                unique: true
            );

            migrationBuilder.CreateIndex(name: "UK_CorporateCustomers_TaxNo", table: "CorporateCustomers", column: "TaxNo", unique: true);

            migrationBuilder.CreateIndex(name: "UK_Customers_UserId", table: "Customers", column: "UserId", unique: true);

            migrationBuilder.CreateIndex(name: "IX_EmailAuthenticators_UserId", table: "EmailAuthenticators", column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_FindeksCreditRates_CustomerId",
                table: "FindeksCreditRates",
                column: "CustomerId",
                unique: true
            );

            migrationBuilder.CreateIndex(name: "UK_Fuels_Name", table: "Fuels", column: "Name", unique: true);

            migrationBuilder.CreateIndex(
                name: "UK_IndividualCustomers_CustomerId",
                table: "IndividualCustomers",
                column: "CustomerId",
                unique: true
            );

            migrationBuilder.CreateIndex(
                name: "UK_IndividualCustomers_NationalIdentity",
                table: "IndividualCustomers",
                column: "NationalIdentity",
                unique: true
            );

            migrationBuilder.CreateIndex(name: "IX_Invoices_CustomerId", table: "Invoices", column: "CustomerId");

            migrationBuilder.CreateIndex(name: "IX_Models_BrandId", table: "Models", column: "BrandId");

            migrationBuilder.CreateIndex(name: "IX_Models_FuelId", table: "Models", column: "FuelId");

            migrationBuilder.CreateIndex(name: "IX_Models_TransmissionId", table: "Models", column: "TransmissionId");

            migrationBuilder.CreateIndex(name: "UK_Models_Name", table: "Models", column: "Name", unique: true);

            migrationBuilder.CreateIndex(name: "UK_OperationClaims_Name", table: "OperationClaims", column: "Name", unique: true);

            migrationBuilder.CreateIndex(name: "IX_OtpAuthenticators_UserId", table: "OtpAuthenticators", column: "UserId");

            migrationBuilder.CreateIndex(name: "IX_RefreshTokens_UserId", table: "RefreshTokens", column: "UserId");

            migrationBuilder.CreateIndex(name: "IX_Rentals_CarId", table: "Rentals", column: "CarId");

            migrationBuilder.CreateIndex(name: "IX_Rentals_CustomerId", table: "Rentals", column: "CustomerId");

            migrationBuilder.CreateIndex(
                name: "IX_Rentals_RentEndRentalBranchId",
                table: "Rentals",
                column: "RentEndRentalBranchId",
                unique: true,
                filter: "[RentEndRentalBranchId] IS NOT NULL"
            );

            migrationBuilder.CreateIndex(
                name: "IX_Rentals_RentStartRentalBranchId",
                table: "Rentals",
                column: "RentStartRentalBranchId",
                unique: true
            );

            migrationBuilder.CreateIndex(
                name: "IX_RentalsAdditionalServices_AdditionalServiceId",
                table: "RentalsAdditionalServices",
                column: "AdditionalServiceId"
            );

            migrationBuilder.CreateIndex(
                name: "IX_RentalsAdditionalServices_RentalId",
                table: "RentalsAdditionalServices",
                column: "RentalId"
            );

            migrationBuilder.CreateIndex(name: "UK_Transmissions_Name", table: "Transmissions", column: "Name", unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_UserOperationClaims_OperationClaimId",
                table: "UserOperationClaims",
                column: "OperationClaimId"
            );

            migrationBuilder.CreateIndex(
                name: "UK_UserOperationClaims_UserId_OperationClaimId",
                table: "UserOperationClaims",
                columns: new[] { "UserId", "OperationClaimId" },
                unique: true
            );

            migrationBuilder.CreateIndex(name: "UK_Users_Email", table: "Users", column: "Email", unique: true);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(name: "CarDamages");

            migrationBuilder.DropTable(name: "CorporateCustomers");

            migrationBuilder.DropTable(name: "EmailAuthenticators");

            migrationBuilder.DropTable(name: "FindeksCreditRates");

            migrationBuilder.DropTable(name: "IndividualCustomers");

            migrationBuilder.DropTable(name: "Invoices");

            migrationBuilder.DropTable(name: "OtpAuthenticators");

            migrationBuilder.DropTable(name: "RefreshTokens");

            migrationBuilder.DropTable(name: "RentalsAdditionalServices");

            migrationBuilder.DropTable(name: "UserOperationClaims");

            migrationBuilder.DropTable(name: "AdditionalServices");

            migrationBuilder.DropTable(name: "Rentals");

            migrationBuilder.DropTable(name: "OperationClaims");

            migrationBuilder.DropTable(name: "Cars");

            migrationBuilder.DropTable(name: "Customers");

            migrationBuilder.DropTable(name: "Colors");

            migrationBuilder.DropTable(name: "Models");

            migrationBuilder.DropTable(name: "RentalBranches");

            migrationBuilder.DropTable(name: "Users");

            migrationBuilder.DropTable(name: "Brands");

            migrationBuilder.DropTable(name: "Fuels");

            migrationBuilder.DropTable(name: "Transmissions");
        }
    }
}
